const {User} = require('../../../models/User');

module.exports = async (req, res) => {
	const {user_id, add_no,consignee,phoneNumber,area,detailAddress,postalCode} = req.body;
    try{
    const update = await User.updateOne({user_id:user_id,"receivingAddress.add_no":add_no},
        {$set:{"receivingAddress.$.consignee":consignee,
               "receivingAddress.$.phoneNumber":phoneNumber,
               "receivingAddress.$.area":area,
               "receivingAddress.$.detailAddress":detailAddress,
               "receivingAddress.$.postalCode":postalCode
        }})
        res.send({errCode:"0",msg:"地址修改成功"})
    }catch(e){
        res.status(400).send({errCode:"1",msg:"修改失败"})
    }
}